package com.indigon.parkStory.view.objects.ui
{
	import com.indigon.parkStory.model.objects.FrogModel;
	import com.indigon.parkStory.view.objects.ObjectView;

	public class RangeView extends ObjectView
	{
		public static const ID : String = "range"; 
		
		private  static const ROTATION_SPEED : Number = 0.2;
		
		public function RangeView(frog:FrogModel)
		{
			super(new GFX_Range(), frog);
			
			graphic.visible = false;
		}
		
		public function reset():void
		{
			graphic.parent.removeChild(graphic);
		}
		
		public function show():void
		{
			setSize();
			place(_object.pos.x, _object.pos.y);
			graphic.visible = true;
		}
		
		public function hide():void
		{
			graphic.visible = false;
		}
		
		public function setSize():void
		{
			var frog : FrogModel = FrogModel(_object);
			graphic.rotation = 0;
			graphic.width = frog.jumpRange * 2;
			graphic.height = frog.jumpRange * 2;
		}
		
		public override function update():void
		{
			if (graphic.visible)
			{
				graphic.rotation += ROTATION_SPEED;
				place(_object.pos.x, _object.pos.y);
			}
		}
	}
}